#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void* foo_write(void* fp)
{
	char str[] = "scarborough fair\n";
	for(int i = 0; i < 20; ++i)
	{
		fwrite(str, sizeof(str), 1, (FILE*)fp);
	
	}
}

int main()
{
	FILE* fp;
	pthread_t tid;
	fp = fopen("data.txt", "w+");
	pthread_create(&tid, NULL, foo_write, fp);
	pthread_create(&tid, NULL, foo_write, fp);
	pthread_create(&tid, NULL, foo_write, fp);

	sleep(20);
	return 0;
}

